library(stargazer)
Please cite as:
Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
# head(acs2)
acsmaritalstatus <-
acsfull %>%
filter(MAR %in% c(1,3)) %>%
select(c(AGEP,MAR,WAGP,COW,RAC1P,SEX,SCHL,NAICSP,FMARHDP,MARHD,MARHYP)) %>%
mutate(sexlabel = case_when(SEX == 1 ~ "male",
SEX == 2 ~ "female")) %>%
mutate(marstatus = case_when(MAR == 1 ~ "married",
MAR == 3 ~ "divorced")) %>%
mutate(classstatus = case_when(COW == "b" ~ "N/A",
COW == 1 ~ "Employee of Private For-Profit",
COW == 2 ~ "Employee of Private Not-For-Profit",
COW == 3 ~ "Employee of Local Govt",
COW == 4 ~ "Employee of State Govt",
COW == 5 ~ "Employee of Federal Govt",
COW == 6 ~ "Self-Employed, Not Incorporated",
COW == 7 ~ "Self-Employed, Incorporated",
COW == 8 ~ "Working without Pay in Family Biz/Farm",
COW == 9 ~ "Unemployed")) %>%
mutate(education = case_when(SCHL == "bb" ~ 0,
SCHL == 01 ~ 0,
SCHL == 02 ~ 0,
SCHL == 03 ~ 0,
SCHL == 04 ~ 1,
SCHL == 05 ~ 2,
SCHL == 06 ~ 3,
SCHL == 07 ~ 4,
SCHL == 08 ~ 5,
SCHL == 09 ~ 6,
SCHL == 10 ~ 7,
SCHL == 11 ~ 8,
SCHL == 12 ~ 9,
SCHL == 13 ~ 10,
SCHL == 14 ~ 11,
SCHL == 15 ~ 11.5,
SCHL == 16 ~ 12,
SCHL == 17 ~ 11.75,
SCHL == 18 ~ 12.5,
SCHL == 19 ~ 13,
SCHL == 20 ~ 14,
SCHL == 21 ~ 16.5,
SCHL == 22 ~ 18,
SCHL == 23 ~ 19.5,
SCHL == 24 ~ 23)) %>%
mutate(exp = AGEP - education - 5) %>%
mutate(expsqd = exp^2) %>%
mutate(lnwages = log(WAGP))
# smallsetb <-
# acs2 %>%
# filter(SERIALNO == 367)
# write.csv(smallsetb, file = "C:/Users/asbru/Documents/Emory/Advanced Mangerial Econ & Data Analytics/Assignment 2/smallsetb.csv")
correlation <-
acs1 %>%
select(c(JWTR,LANX,MAR,SCHL))
M <-
cor(correlation)
# png(file="corr.png", res=300, width=4500, height=4500)
corrplot(M, method = "shade", number.cex = 1, tl.cex = 1, title = "All Positions", mar=c(0,0,1,0))
hist1<-
acsmaritalstatus %>%
ggplot( aes(x=education)) +
geom_histogram(bins = 24)
ggplotly(hist1)
BoxPlot1 <-
acsmaritalstatus %>%
ggplot(aes(MAR, WAGP)) +
geom_boxplot(aes(group=MAR, color=MAR)) +
facet_wrap(~SEX) +
stat_compare_means(label = "p.format")
BoxPlot1
#Yes there appears to be a statistically significant difference in the means between both married/divorced males and females.
BoxPlot2 <-
acsmaritalstatus %>%
ggplot(aes(SEX, WAGP)) +
geom_boxplot(aes(group=SEX, color=SEX)) +
facet_wrap(~MAR) +
stat_compare_means(label = "p.format")
BoxPlot2
ACS_divorced_married_men <-
acsmaritalstatus %>%
filter(sexlabel == "male")
ACS_divorced_married_women <-
acsmaritalstatus %>%
filter(sexlabel == "female")
ACS_divorced <-
acsmaritalstatus %>%
filter(marstatus == "divorced")
ACS_married <-
acsmaritalstatus %>%
filter(marstatus == "married")
#ALL
LinearModel1 <- lm(WAGP ~ education + exp + expsqd
+ MAR
+ SEX
+ COW
,data = acsmaritalstatus)
summary(LinearModel1)
Call:
lm(formula = WAGP ~ education + exp + expsqd + MAR + SEX + COW,
data = acsmaritalstatus)
Residuals:
Min 1Q Median 3Q Max
-114924 -27946 -8681 13462 635742
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.001e+04 3.693e+02 -27.1 <2e-16 ***
education 5.543e+03 1.648e+01 336.3 <2e-16 ***
exp 2.035e+03 1.440e+01 141.4 <2e-16 ***
expsqd -3.706e+01 2.328e-01 -159.2 <2e-16 ***
MAR -3.413e+03 6.731e+01 -50.7 <2e-16 ***
SEX -2.344e+04 1.006e+02 -233.1 <2e-16 ***
COW -3.652e+03 2.565e+01 -142.4 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 54940 on 1211286 degrees of freedom
(396376 observations deleted due to missingness)
Multiple R-squared: 0.159, Adjusted R-squared: 0.159
F-statistic: 3.817e+04 on 6 and 1211286 DF, p-value: < 2.2e-16
#Only Men
LinearModel_Men <- lm(WAGP ~ education + exp + expsqd
+ MAR
+ COW
,data = ACS_divorced_married_men)
#Only Women
LinearModel_Women <- lm(WAGP ~ education + exp + expsqd
+ MAR
+ COW
,data = ACS_divorced_married_women)
#Only Divorced
LinearModel_Divorced <- lm(WAGP ~ education + exp + expsqd
+ SEX
+ COW
,data = ACS_divorced)
#Only Married
LinearModel_Married <- lm(WAGP ~ education + exp + expsqd
+ SEX
+ COW
,data = ACS_married)
summary(LinearModel_Men)
Call:
lm(formula = WAGP ~ education + exp + expsqd + MAR + COW, data = ACS_divorced_married_men)
Residuals:
Min 1Q Median 3Q Max
-125882 -33794 -12167 14723 628392
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -42527.282 557.268 -76.31 <2e-16 ***
education 6441.566 26.076 247.03 <2e-16 ***
exp 2383.385 24.215 98.43 <2e-16 ***
expsqd -43.958 0.379 -115.98 <2e-16 ***
MAR -7948.700 119.922 -66.28 <2e-16 ***
COW -4103.825 40.068 -102.42 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 65320 on 622958 degrees of freedom
(162292 observations deleted due to missingness)
Multiple R-squared: 0.1442, Adjusted R-squared: 0.1442
F-statistic: 2.099e+04 on 5 and 622958 DF, p-value: < 2.2e-16
summary(LinearModel_Women)
Call:
lm(formula = WAGP ~ education + exp + expsqd + MAR + COW, data = ACS_divorced_married_women)
Residuals:
Min 1Q Median 3Q Max
-77565 -21630 -6557 12066 618538
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.045e+04 3.685e+02 -109.778 <2e-16 ***
education 4.346e+03 1.845e+01 235.491 <2e-16 ***
exp 1.487e+03 1.527e+01 97.328 <2e-16 ***
expsqd -2.680e+01 2.565e-01 -104.453 <2e-16 ***
MAR 1.057e+02 6.677e+01 1.583 0.113
COW -2.876e+03 2.918e+01 -98.537 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 40510 on 588323 degrees of freedom
(234084 observations deleted due to missingness)
Multiple R-squared: 0.1226, Adjusted R-squared: 0.1226
F-statistic: 1.645e+04 on 5 and 588323 DF, p-value: < 2.2e-16
summary(LinearModel_Divorced)
Call:
lm(formula = WAGP ~ education + exp + expsqd + SEX + COW, data = ACS_divorced)
Residuals:
Min 1Q Median 3Q Max
-85810 -23698 -7529 12895 600260
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.092e+04 7.701e+02 -27.16 <2e-16 ***
education 4.330e+03 3.478e+01 124.50 <2e-16 ***
exp 1.370e+03 3.320e+01 41.26 <2e-16 ***
expsqd -2.501e+01 5.031e-01 -49.72 <2e-16 ***
SEX -8.777e+03 1.933e+02 -45.40 <2e-16 ***
COW -2.779e+03 5.025e+01 -55.31 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 43040 on 205066 degrees of freedom
(72798 observations deleted due to missingness)
Multiple R-squared: 0.1102, Adjusted R-squared: 0.1101
F-statistic: 5077 on 5 and 205066 DF, p-value: < 2.2e-16
summary(LinearModel_Married)
Call:
lm(formula = WAGP ~ education + exp + expsqd + SEX + COW, data = ACS_married)
Residuals:
Min 1Q Median 3Q Max
-118367 -28817 -8950 13563 640151
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.221e+04 4.059e+02 -30.09 <2e-16 ***
education 5.701e+03 1.840e+01 309.75 <2e-16 ***
exp 2.176e+03 1.594e+01 136.49 <2e-16 ***
expsqd -3.989e+01 2.607e-01 -153.01 <2e-16 ***
SEX -2.642e+04 1.142e+02 -231.30 <2e-16 ***
COW -3.788e+03 2.899e+01 -130.65 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 56910 on 1006215 degrees of freedom
(323578 observations deleted due to missingness)
Multiple R-squared: 0.1643, Adjusted R-squared: 0.1643
F-statistic: 3.956e+04 on 5 and 1006215 DF, p-value: < 2.2e-16
stargazer(LinearModel_Divorced, type = "latex")
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changed % Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu % Date and time: Wed, Jan 08, 2020 - 1:48:01 PM
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changed